package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Author：毕龙
 * Date: 2023/7/27 16:10
 */
@WebServlet("/rr1")
public class RequestRedirect1 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request,
                           HttpServletResponse response) throws ServletException, IOException {
        System.out.println("我想给张何晴一个水杯的盖子....");

        request.setAttribute("name","xieyucheng");

        /**
         * 重定向 定向的路径必须是全路径
         *   必须添加网络资源的应用名
         *   request.getContextPath() 获取资源路径 /ems
         */
        //response.sendRedirect("/ems/zs");
        response.sendRedirect(request.getContextPath()+"/zs");
    }
}
